package com.dabai.simpleconnection_udp.utils.charset;

import com.ibm.icu.text.CharsetDetector;
import com.ibm.icu.text.CharsetMatch;

public class CharsetUtils {

    public static String getCharset(String data) {
        CharsetDetector detector = new CharsetDetector();
        detector.setText(data.getBytes());
        CharsetMatch match = detector.detect();
        return match.getName();
    }
    public static String getCharset(byte[] data) {
        CharsetDetector detector = new CharsetDetector();
        detector.setText(data);
        CharsetMatch match = detector.detect();
        return match.getName();
    }



}
